package com.xgggh.redpack.ui.my;

import android.os.Bundle;
import android.view.ContextMenu;
import android.view.MenuItem;
import android.view.View;

import androidx.annotation.Nullable;
import androidx.databinding.DataBindingUtil;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentPagerAdapter;

import com.xgggh.redpack.R;
import com.xgggh.redpack.base.ui.BaseActivity;
import com.xgggh.redpack.databinding.ActivityMyRedPackBinding;
import com.xgggh.redpack.ui.my.fragment.MyRedPackStatisticsFragment;
import com.xgggh.redpack.ui.my.fragment.RedPackDetailsFragment;

public class MyRedPackActivity extends BaseActivity {
    ActivityMyRedPackBinding mBinding;
    private final int mStatisticsIndex=0;
    private final int mGetRedPackIndex=1;
    private final int mSendRedPackIndex=2;
    private  int mCurrentIndex=mStatisticsIndex;
    Fragment[] fragments = new Fragment[]{
            MyRedPackStatisticsFragment.newInstance(),
            RedPackDetailsFragment.newInstance(),
            RedPackDetailsFragment.newInstance(),
    };

    int[] titleRes = new int[]{
            R.string.my_red_pack_0,
            R.string.my_red_pack_1,
            R.string.my_red_pack_2,
    };

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        mBinding= DataBindingUtil.setContentView(this,R.layout.activity_my_red_pack);
        setSupportActionBar(mBinding.toolbar.toolbar);

        FragmentPagerAdapter adapter=new FragmentPagerAdapter(getSupportFragmentManager()) {
            @Override
            public Fragment getItem(int i) {
                return fragments[i];
            }

            @Override
            public int getCount() {
                return fragments.length;
            }
            @Nullable
            @Override
            public CharSequence getPageTitle(int position) {
                return getString(titleRes[position]);
            }
        };
        //ViewPager2 v= mBinding.viewPager;
        mBinding.viewPager.setOffscreenPageLimit(fragments.length);
        mBinding.viewPager.setAdapter(adapter);
        mBinding.tabLayout.setupWithViewPager(mBinding.viewPager);
    }

    @Override
    public void onCreateContextMenu(ContextMenu menu, View v, ContextMenu.ContextMenuInfo menuInfo) {
        super.onCreateContextMenu(menu, v, menuInfo);
        //时间赛选或者红包类型赛选
    }

    @Override
    public boolean onOptionsItemSelected(MenuItem item) {
        return super.onOptionsItemSelected(item);
    }





    private void redPackGetList(){

    }


    private void redPackSendList(){

    }
}
